package object;

public class ObjectDemo {
    public static void main(String[] args) {

        Point p1=new Point(6,6);
        Point p2=new Point(6,6);
        System.out.println(p1==p2);//false == 比较的是地址
        //依然是false 因为Object类中的equals()内部还是用==比较地址
        //所以我们常常需要重写equals()
        System.out.println(p1.equals(p2));

        String s1=new String("cxk");
        String s2=new String("cxk");
        System.out.println(s1.equals(s2));//true

        StringBuilder stringBuilder1=new StringBuilder("cxk");
        StringBuilder stringBuilder2=new StringBuilder("cxk");
        System.out.println(stringBuilder1.equals(stringBuilder2));//false
        //StringBuilder没有重写equals()所以依旧调用的Object中的equals()

        System.out.println(s1.equals(stringBuilder1));
        //false，s1和stringBuilder1的类型不同，所以false







        /*
      Point p=new Point(100,200);
      System.out.println(p);
      System.out.println(p.toString());//object.Point@1b6d3586,重写后100，200


         */
      /*

       输出引用变量时默认调用Object类的toString()方法
       类的全称@hashcode
       常常重写toString()来返回具体的属性值
       */



    }
}
